<!---
Copyright: (c) 2006 The MachBlog Authors
Authors: Matt Woodward (mpwoodward@gmail.com) & Peter J. Farrell (pjf@maestropublishing.com)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. 
You may obtain a copy of the License at 

http://www.apache.org/licenses/LICENSE-2.0 

Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions and 
limitations under the License.

$Id: CommentGateway.cfc 1190 2007-07-14 17:22:31Z pfarrell $

Notes:
--->
<cfcomponent 
	displayname="CommentGateway" 
	output="false" 
	hint="Base CommentGateway for MachBlog">
	
	<!---
	PROPERTIES
	--->
	<cfproperty name="datasource" type="org.machblog.datasource.Datasource" required="true" />
	<cfproperty name="resourceBundleFacade" type="org.machblog.facades.ResourceBundleFacade" required="true" />
	
	<!---
	INITIALIZATION / CONFIGURATION
	--->
	<cffunction name="init" access="public" output="false" returntype="CommentGateway">
		<cfreturn this />
	</cffunction>
	
	<cffunction name="setDatasource" access="public" output="false" returntype="void"
		hint="Dependency: injected">
		<cfargument name="datasource" type="org.machblog.datasource.Datasource" required="true" />
		<cfset variables.datasource = arguments.datasource />
	</cffunction>
	<cffunction name="getDatasource" access="public" output="false" 
			returntype="org.machblog.datasource.Datasource">
		<cfreturn variables.datasource />
	</cffunction>

	<cffunction name="setResourceBundleFacade" access="public" output="false" returntype="void"
		hint="Dependency: injected">
		<cfargument name="resourceBundleFacade" type="org.machblog.facades.ResourceBundleFacade" required="true" />
		<cfset variables.resourceBundleFacade = arguments.resourceBundleFacade />
	</cffunction>
	<cffunction name="getResourceBundleFacade" access="public" output="false" 
			returntype="org.machblog.facades.ResourceBundleFacade">
		<cfreturn variables.resourceBundleFacade />
	</cffunction>

	<!---
	PUBLIC FUNCTIONS
	--->
	<cffunction name="getComments" access="public" output="false" returntype="query" 
		hint="Returns a query containing recent comments across all entries">
		<cfargument name="entryId" type="string" required="false" default="" />
		<cfargument name="numToGet" type="numeric" required="false" default="-1" />
		<cfargument name="includeInactive" type="boolean" required="false" default="false" />
		<cfargument name="searchTerms" type="string" required="false" default="" />
		<cfargument name="sortOrder" type="string" required="false" default="ASC" />
	</cffunction>
	
	<cffunction name="getCommentCount" access="public" output="false" returntype="numeric" 
		hint="Returns the number of comments, optionally for a specific date.">
		<cfargument name="commentDate" type="date" required="false" default="#CreateDate(1900, 1, 1)#" />
	</cffunction>
	
	<cffunction name="getSubscriptionCount" access="public" output="false" returntype="numeric" 
		hint="Returns the total number of comment subscriptions across the entire blog">
	</cffunction>

	<cffunction name="deactivateCommentsByEntryId" access="public" output="false" returntype="void" 
		hint="Deactivates all comments for a particular entry">
		<cfargument name="entryId" type="uuid" required="true" />
	</cffunction>
	
	<cffunction name="activateCommentsByEntryId" access="public" output="false" returntype="void" 
		hint="Activates all comments for a particular entry">
		<cfargument name="entryId" type="uuid" required="true" />
	</cffunction>
	
	<cffunction name="deleteCommentsByEntryId" access="public" output="false" returntype="void" 
		hint="Deletes all comments associated with a particular entry">
		<cfargument name="entryId" type="uuid" required="true" />
	</cffunction>
	
	<cffunction name="toggleCommentDisplay" access="public" output="false" returntype="void" 
		hint="Approves or unapproves a comment">
		<cfargument name="commentId" type="uuid" required="true" />
		<cfargument name="adminId" type="uuid" required="true" />
	</cffunction>
	
	<cffunction name="toggleIpBlock" access="public" output="false" returntype="void" 
		hint="Adds or removes an IP to/from the block list">
		<cfargument name="ipAddress" type="string" required="true" />
		<cfargument name="action" type="string" required="true" />
		<cfargument name="adminId" type="uuid" required="true" />
	</cffunction>
	
	<cffunction name="deleteComments" access="public" output="false" returntype="void" 
		hint="Deletes comments">
		<cfargument name="deleteIds" type="string" required="true" />
	</cffunction>
	
	<cffunction name="getCommentSubscribers" access="public" output="false" returntype="query" 
		hint="Returns a query containing email addresses for people subscribed to comments for a particular entry">
		<cfargument name="entryId" type="uuid" required="true" />
	</cffunction>

</cfcomponent>